Open History to see the last commit
1import React from 'react'
2import Link from 'next/link'
3import fetch from '../../libs/fetch'
4β
5import { useQuery } from '@tanstack/react-query'
6β
7export default () => {
8 const id =
9 typeof window !== 'undefined' ? window.location.pathname.slice(1) : ''
10β
11 const { status, data, error, isFetching } = useQuery(['team', id], () =>
12 fetch('/api/data?id=' + id),
13 )
14β
15 return (
16 <div style={{ textAlign: 'center' }}>
17 <h1>{id}</h1>
18 {status === 'loading' ? (
19 'Loading...'
20 ) : status === 'error' ? (
21 <span>Error: {error.message}</span>
22 ) : (
23 <>
24 <div>
25 <p>forks: {data.forks_count}</p>
26 <p>stars: {data.stargazers_count}</p>
27 <p>watchers: {data.watchers}</p>
28 </div>
29 <div>{isFetching ? 'Background Updating...' : ' '}</div>
30 </>
31 )}
32 <br />
33 <br />
34 <Link href="/">
35 <a>Back</a>
36 </Link>
37 </div>
38 )
39}